﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;
using BusinessComponents.Managers;
using BusinessComponents.DomainModels;

namespace WaterfrontLodge.WebForms.Report
{
    public partial class RPT2001 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Chart1.ImageStorageMode = System.Web.UI.DataVisualization.Charting.ImageStorageMode.UseImageLocation;

            Chart1.Series["Default"].ChartType = SeriesChartType.Pie;
            Chart1.Titles[0].Text = "Room Type Popularity";
            Chart1.Titles[0].ToolTip = "Display the popularity of different room types in terms of day.";

            IEnumerable<Report2001> list = ManagerFactory.ReportMgr.fetchRpt2001();
            foreach(var rpt in list){
                string ratio =  string.Format("{0:f1}", rpt.Ratio*100) + "%";
                int pos = Chart1.Series["Default"].Points.AddXY(rpt.RoomType + " " + ratio, rpt.Ratio);
                if (rpt.Expanded)
                {
                    Chart1.Series["Default"].Points[pos]["Exploded"] = "true";
                }
            }

            Chart1.Series["Default"]["PieLabelStyle"] = "Outside";
            Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            Chart1.Legends[0].Enabled = true;
            Chart1.DataBind();
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("/WebForms/Report/ReportList.aspx", true);
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {

        }
        #endregion
    }
}